<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="box"></div>
    <script>
      let box = document.getElementById("box");
      let personList = [
        { name: "小明", age: 12, hobby: "篮球" },
        { name: "小红", age: 11, hobby: "花花" },
        { name: "小花", age: 12, hobby: "骑单车" },
      ];
      for (let item of personList) {
        console.log(item);
        let person = document.createElement("ul");
        person.innerText = item.name;
        let age = document.createElement("li");
        age.className = "age";
        age.innerText = "年龄：" + item.age;
        person.appendChild(age);
        let hobby = document.createElement("li");
        hobby.innerText = "爱好：" + item.hobby;
        person.appendChild(hobby);
        box.appendChild(person);
      }
    </script>
  </body>
</html>
